<template>
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false"
             v-dialogDrag>
    <div class="app-container">
      <!-- <el-table border v-loading="loading" :data="dataList"  ref="table"
                :max-height="tableMaxHeight">
        <el-table-column label="到货重量" align="center" prop="dunwei"/>
        <el-table-column label="运费" align="center" prop="yunfei"/>
        <el-table-column label="是否打款" align="center" prop="isSong"/>
        <el-table-column label="送货人" align="center" prop="songhuoren"/>
        <el-table-column label="送货人电话" align="center" prop="songhuotel"/>
        <el-table-column label="送货人开户行" align="center" prop="songkaihuhang"/>
        <el-table-column label="开户行账号" align="center" prop="songzhanghao"/>
        <el-table-column label="打款人" align="center" prop="ddSongpeople"/>
        <el-table-column label="打款日期" align="center" prop="ddDatepeople" />
        <el-table-column label="打款记录" align="center" prop="ddSongfile"/>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit"
                v-show="scope.row.isSong=='否'"       @click="dakuanYunfei(scope.row)" v-hasPermi="['develop:LvBuy:edit']">打款</el-button>
          </template>
        </el-table-column>
      </el-table> -->

      <el-form ref="form" :model="form"  label-width="120px">
            <el-tabs  class="detail-tab" type="card">
                <el-tab-pane label="运费明细" >
                  <el-row :gutter="20">
                      <el-col :span="12">
                          <el-form-item label="到货重量" prop="dunwei">
                            <el-input v-model="form.dunwei" :disabled="true" />
                          </el-form-item>
                      </el-col>
                      <el-col :span="12">
                          <el-form-item label="运费" prop="yunfei">
                              <el-input v-model="form.yunfei" :disabled="true" />
                          </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="是否打款" prop="isSong">
                          <el-input v-model="form.isSong" :disabled="true" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="送货人" prop="songhuoren">
                        <el-input v-model="form.songhuoren" :disabled="true" />
                    </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="送货人电话" prop="songhuotel">
                        <el-input v-model="form.songhuotel" :disabled="true" />
                    </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="送货人开户行" prop="songkaihuhang">
                        <el-input v-model="form.songkaihuhang" :disabled="true" />
                    </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="开户行账号" prop="songzhanghao">
                        <el-input v-model="form.songzhanghao" :disabled="true" />
                    </el-form-item>
                      </el-col>
                      <el-col :span="12" v-if="form.ddSongpeople">
                        <el-form-item label="打款人" prop="ddSongpeople">
                        <el-input v-model="form.ddSongpeople" :disabled="true" />
                    </el-form-item>
                      </el-col>
                      <el-col :span="12" v-if="form.ddDatepeople">
                        <el-form-item label="打款日期" prop="ddDatepeople">
                        <el-input v-model="form.ddDatepeople" :disabled="true" />
                    </el-form-item>
                      </el-col>
                  </el-row>
                    <el-form-item label="打款记录" prop="ddSongfile">
                      <file-upload v-model="form.ddSongfile"/>
                    </el-form-item>
                </el-tab-pane>
            </el-tabs>
        </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm" v-show="form.isSong=='否'"  >打 款</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { updateAction,getById} from '@/api/manage'

  export default {
    name: "YunfeiForm",
    components: {

    },
    data() {
      return {
        title: "运费记录",
        open: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        rows: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 销售信息管理表格数据
        form: {},
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 20,
          mainId: null,
          name: null,
          brand: null,
          unit: null,
          costPrice: null,
          count: null,
          cost: null,
          validityTerm: null,
          buyId: null,
          buyName: null,
          buyDate: null,
          buyType: null,
          reimburse: null,
          supplierId: null,
          supplierName: null,
          dateRange: "",
          params: {},
        },
        url: {
            getByid:'/lvDaohuo/lvDaohuo/',
            edit:'/lvDaohuo/lvDaohuo/editYf',
        },
        tableMaxHeight: window.innerHeight - 320,
      };
    },
    created() {
      // this.intDictsForPrj();
      window.addEventListener('resize', this.getTableHeight);
    },
    destroyed() {
      window.removeEventListener('resize', this.getTableHeight);
    },
    methods: {
      getTableHeight() {
        this.tableHeight = window.innerHeight - 320
      },
      showyunfei(row){
        this.queryParams.id=row.id;
        this.open=true;
        getById(this.url.getByid, row.id).then(response => {
           response.data;
          this.form = response.data;
          this.loading = false;
        });
      },
      cancel () {
        this.open=false;
      },
      // 确定打款按钮
      submitForm() {
        if (this.form.id != null) {
          updateAction(this.url.edit, this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.$emit('ok');
          });
        }
      },
    }
  };
</script>
